import os
import array

sizes = [14, 8, 14, 14, 14, 14, 14, 14, 14, 14, 5]        
    
if __name__ == "__main__":
    print "<i> Convertendo formato de fontes da pasta atual"
    flist = [f for f  in os.listdir(os.getcwd()) if (f[-3:] == "bin") and (f[:7] == "[raw16]")]
    ###
    for item in flist:
        ###
        size = os.path.getsize(item)
        print "\tNome:\t\t", item, "\n\tTamanho:\t", size, " bytes"
        ###
        binFile = open(item,"rb")
        data = [ord(n) for n in binFile.read(size)]
        binFile.close()
        print "<i> Convertendo dados..."

        ###
        x = 0
        t = 0
        tmp = open(item[7:],"wb")
        
        while( x < size):
            tmp.write( chr(sizes[t]) )
            tmp.write("".join([chr(c) for c in data[x:x+32]]))
            x = x + 32
            t = t + 1
        tmp.close()
